package com.sunday.common.mq.kafka.study.spring.e11_Serialization_Deserialization_Message_Conversion;

import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.common.utils.Bytes;
import org.springframework.kafka.annotation.KafkaHandler;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@KafkaListener(
        id = "myId_7",
        topics = "topic7",
        clientIdPrefix = "TEST7",
        errorHandler = "validationErrorHandler"
)
public class MultiListenerBean {

    @KafkaHandler
    public void listen(Byte[] byteArr) {
        log.info("[Byte[]] : {}", byteArr);
    }

    @KafkaHandler
    public void listen(Bytes bytes) {
        log.info("[Bytes] : {}", bytes);
    }

    @KafkaHandler
    public void listen(String foo) {
        log.info("[foo] : {}", foo);
    }

    @KafkaHandler
    public void listen(@Payload @Valid ValidatedClass validatedClass) {
        log.info("[validatedClass] : {}", validatedClass);
    }

    @KafkaHandler
    public void listen(Integer bar) {
        log.info("[bar] : {}", bar);
    }

    @KafkaHandler(isDefault = true)
    public void listenDefault(Object object) {
        log.info("[object] : {}", object);
    }

}
